﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using SLRT.commands;
using SLRT.usercontrols;
using SLRT.business.src;

namespace SLRT.viewmodel
{
    public class MainViewModel
    {
        private DelegateCommand exitCommand;
        private DelegateCommand newButtonCommand;
        private static int counter = 0;
        private MainWindow mw;

        public MainViewModel(MainWindow mw)
        {
            this.mw = mw;
        }

        public ICommand ExitCommand
        {
            get
            {
                if (exitCommand == null)
                {
                    exitCommand = new DelegateCommand(Exit);
                }
                return exitCommand;
            }
        }

        public ICommand NewButtonCommand
        {
            get
            {
                if (newButtonCommand == null)
                {
                    newButtonCommand = new DelegateCommand(NewButton);
                }
                return newButtonCommand;
            }

        }


        private void Exit()
        {
            Application.Current.Shutdown();
        }

        private void NewButton()
        {
            Button newBtn = new Button();
            newBtn.Name = "btn" + counter;
            newBtn.Content = "A New Button " + counter;
            newBtn.Height = 30;
            newBtn.Width = 100;
            counter++;
            newBtn.Click += new RoutedEventHandler(newBtn_Click);
            //mw.dockpanel.Children.Add(newBtn);

        }

        private void newBtn_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("New Button Clicked!", "I got pressed.");
        }
    }
}
